﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace frost
{
    class SpelMatrix
    {
        public struct Cell
        {
            public char typ_of_cell;
            public bool visited;
        };

        public Cell[,] myMatrix = new Cell[20,20];
        public Random rand1 = new Random(23);

        public SpelMatrix()
        {
            for(int i = 0; i < 20; i++)
	        {
                for (int j = 0; j < 20; j++)
                {
                    myMatrix[i,j].typ_of_cell = ' ';
                    myMatrix[i,j].visited = false;
                }
	        }

        }

        public void init()
        {
            //srand(time(NULL));
            int i = 0;
            int x, y;

            //Sätter ut fällor slumpmässigt
            while (i < 5)
            {
                x = rand1.Next(20);
                y = rand1.Next(20);
                if (myMatrix[x,y].typ_of_cell != 'T')
                {
                    myMatrix[x,y].typ_of_cell = 'T';
                    i++;
                }
            }


            //Sätter ut målet slumpmässigt
            i = 0;
            while (i < 1)
            {
                x = rand1.Next(20);
                y = rand1.Next(20);
                if (myMatrix[x,y].typ_of_cell != 'T')
                {
                    myMatrix[x,y].typ_of_cell = 'X';
                    i++;
                }
            }
        }

        public void SetVisit( int x, int y )
        {
	        myMatrix[x,y].visited = true;
	        //Console::gotoxy(STARTX + x*2 + 1,STARTY + y*2 + 1);
	        //cout << '*';
        }

        public char GetTypOfCell( int x, int y )
        {
	        return myMatrix[x,y].typ_of_cell;
        }

        public void draw(Graphics g)
        {
            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    g.DrawString(myMatrix[i,j].typ_of_cell.ToString(), new Font("Doktor Terror", 24),
                            Brushes.Red, i*20,j*20);
                }
            }
        }
    }
}